/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Administrator
 */
public class NewJFrame extends javax.swing.JFrame {

    /**
     * Creates new form NewJFrame
     */
    public NewJFrame() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        ScreenJF = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jBnAC = new javax.swing.JButton();
        jBnadd = new javax.swing.JButton();
        jBnsubstrct = new javax.swing.JButton();
        jBnmultiply = new javax.swing.JButton();
        jBn7 = new javax.swing.JButton();
        jBn8 = new javax.swing.JButton();
        jBn9 = new javax.swing.JButton();
        jBndivide = new javax.swing.JButton();
        jBn4 = new javax.swing.JButton();
        jBn5 = new javax.swing.JButton();
        jBn6 = new javax.swing.JButton();
        jBnmeans = new javax.swing.JButton();
        jBn1 = new javax.swing.JButton();
        jBn2 = new javax.swing.JButton();
        jBn3 = new javax.swing.JButton();
        jBn0 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(102, 102, 255));

        ScreenJF.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        ScreenJF.setText("0");
        ScreenJF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ScreenJFActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ScreenJF)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ScreenJF, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel2.setBackground(new java.awt.Color(255, 0, 0));
        jPanel2.setLayout(new java.awt.GridLayout(4, 4));

        jBnAC.setText("AC");
        jPanel2.add(jBnAC);

        jBnadd.setText("+");
        jPanel2.add(jBnadd);

        jBnsubstrct.setText("-");
        jPanel2.add(jBnsubstrct);

        jBnmultiply.setText("*");
        jPanel2.add(jBnmultiply);

        jBn7.setText("7");
        jPanel2.add(jBn7);

        jBn8.setText("8");
        jPanel2.add(jBn8);

        jBn9.setText("9");
        jPanel2.add(jBn9);

        jBndivide.setText("/");
        jPanel2.add(jBndivide);

        jBn4.setText("4");
        jPanel2.add(jBn4);

        jBn5.setText("5");
        jPanel2.add(jBn5);

        jBn6.setText("6");
        jPanel2.add(jBn6);

        jBnmeans.setText("=");
        jPanel2.add(jBnmeans);

        jBn1.setText("1");
        jBn1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBn1ActionPerformed(evt);
            }
        });
        jPanel2.add(jBn1);

        jBn2.setText("2");
        jPanel2.add(jBn2);

        jBn3.setText("3");
        jPanel2.add(jBn3);

        jBn0.setText("0");
        jPanel2.add(jBn0);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBn1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBn1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jBn1ActionPerformed
private void doNum(String num){
    if(newInput){
        ScreenJF.setText(0+"");
    }
    if(ScreenJF.getText().trim().equals("0")){
        ScreenJF.setText(num);
    }
}
    private void ScreenJFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ScreenJFActionPerformed
        // TODO add your handling code here:

       
    }//GEN-LAST:event_ScreenJFActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField ScreenJF;
    private javax.swing.JButton jBn0;
    private javax.swing.JButton jBn1;
    private javax.swing.JButton jBn2;
    private javax.swing.JButton jBn3;
    private javax.swing.JButton jBn4;
    private javax.swing.JButton jBn5;
    private javax.swing.JButton jBn6;
    private javax.swing.JButton jBn7;
    private javax.swing.JButton jBn8;
    private javax.swing.JButton jBn9;
    private javax.swing.JButton jBnAC;
    private javax.swing.JButton jBnadd;
    private javax.swing.JButton jBndivide;
    private javax.swing.JButton jBnmeans;
    private javax.swing.JButton jBnmultiply;
    private javax.swing.JButton jBnsubstrct;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    // End of variables declaration//GEN-END:variables
}
